借助:puppeteer-chromium-resolver,不用再安装puppeteer

npm install puppeteer-chromium-resolver --save
var puppeteerResolver = require("puppeteer-chromium-resolver");
var revisionInfo = await puppeteerResolver({
    revision: "",
    detectionPath: "",
    folderName: '.chromium-browser-snapshots',
    hosts: ["https://storage.googleapis.com", "https://npm.taobao.org/mirrors"],
    retry: 3
});

console.log("Chromium revision installed and launchable is " + revisionInfo.launchable);

var browser = await revisionInfo.puppeteer.launch({
    headless: true,
    args: ['--no-sandbox'],
    executablePath: revisionInfo.executablePath
}).catch(function (error) {
    console.log(error);
});

var page = await browser.newPage();
await page.goto('https://www.google.com');
await browser.close();

jessiedwj
4 声望0 粉丝